<script setup>
import { ref, defineProps } from "vue";
const emit = defineEmits(["change"]);
const props = defineProps({
  modelValue: {
    type: Number,
    default: 1,
  },
});
// 解决switch组件首次赋值变量
const state = ref(false);

const handlerChange = async (val) => {
  if (!state) return (state.value = true);
  emit("change", val);
};
</script>

<template>
  <el-switch
    :active-value="1"
    :inactive-value="2"
    :modelValue="modelValue"
    @change="handlerChange($event)"
  />
</template>




<style lang="scss" scoped>
</style> 